package controller;

import java.util.List;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import pojo.User;
import service.UserService;
import service.UserServiceManager;



@org.springframework.stereotype.Controller

public class Controller {
	private UserService us;
	public Controller(){
		us=UserServiceManager.getServiceImpl();
		
	}
	
	@RequestMapping(value="/addUser",method=RequestMethod.POST)
	public String addUser(User u){
		 
		us.addUser(u);
		return "redirect:/listAll";
	}
	
	@RequestMapping(value="/listAll")
	public String listAll(Model model){
		List<User> list = us.getUsers();
		model.addAttribute("users", list);
		return "show";
	} 

}
